<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>DBLoop Statement</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../edit68k.css" rel="stylesheet" type="text/css">
</head>

<body class="text">
<p class="heading">Structured Control - DBloop <br>
<hr noshade>
<p><b>DBloop</b> - Implements a loop using the decrement and branch 
conditional instruction (DBcc). After each pass through the loop the data 
register Dn is decremented by 1. The loop continues until Dn = -1 or 
until an optional &lt;expression&gt; is true.</p>
<p>The DBloop statement has the following syntax:</p>
<p class="sourcecode">DBLOOP Dn = <i>op1</i><br>
&nbsp;&nbsp; <i>code</i>&nbsp;<br>
UNLESS[.<i>size</i>] [<i>expression</i>]</p>
<p><i><b>size</b></i> - The value B, W, or L, specifying the size
of the operand comparison.&nbsp; These values correspond to the Byte, Word, or
Long word data size.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
A size may not be specified when the expression consists of only a condition 
code.</p>
<p><i><b>expression</b></i> - The expression tested.&nbsp; For a
description of the expression syntax, see the <a href="exsyntax.htm"> Expression Syntax</a>
page. If the expression field is empty or contains &lt;F&gt; the assembler will output 
a DBRA instruction resulting in a loop that loops op1 + 1 times.</p>
<p><i><b>code</b></i> - The series of assembly commands
executed until the <i><b>expression</b></i> is true or Dn is decremented to -1.</p>
<p><i><b>op1</b></i> - The initial number to be stored in data 
register Dn.&nbsp;
May be any addressing mode.</p>
<p>One space should be used to separate each part of the statement.</p>
<p class="subheading">===Notes===</p>
<p>The <i><b>code</b></i> instructions
are executed once even if the <i><b>expression</b></i> is true upon entry. 
Compound expressions are not supported.</p>
<p>The CCR's (condition code register) flags are modified by this 
command after each execution of the <i><b>code</b></i> instructions.</p>
<p><b>EXAMPLE</b></p>
<p class="sourcecode">DBLOOP D0 = #5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
loops 6 times<br>
&nbsp;&nbsp; <i>code</i><br>
UNLESS.W (A0) &lt;LT&gt; #$200&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit loop if (A0) &lt; 
$200</p>
<p class="sourcecode">DBLOOP D0 = #4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
loops 5 times<br>
&nbsp;&nbsp; <i>code</i><br>
UNLESS</p>
</body>
</html>